package com.ltu.util.common;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ltu.model.request.base.PageReqData;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.data.domain.Sort.Direction;

import java.util.ArrayList;
import java.util.List;


public class MpPageUtil {
    /**
     * 构造mybatis分页查询的结构体
     * @param pageReqData
     * @return
     */
    public static Page getCommonPage(PageReqData pageReqData) {
        Page<T> page=new Page<>(pageReqData.getPageNumber(),pageReqData.getPageSize());
        //排序
        OrderItem  oi = new OrderItem();
        oi.setColumn(pageReqData.getSortType());
        oi.setAsc(true);
        if ("desc".equals(pageReqData.getSortOrder())) 
        	 oi.setAsc(false);
    	page.addOrder(oi);
    	page.setSearchCount(true);
        return page;
    }
}
